



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>nginx的upstream原理解析 &mdash; Nginx开发从入门到精通</title>
    <link rel="stylesheet" href="_static/book.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/comment.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../js/??ga.js,correctpng.js?v=1"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/booktools.js"></script>
    <script type="text/javascript" src="_static/translations.js"></script>
    <script type="text/javascript" src="_static/comment.js"></script>
    <link rel="top" title="Nginx开发从入门到精通" href="index.html" />
    <link rel="up" title="下篇：nginx原理解析篇" href="source_analysis.html" />
    <link rel="next" title="nginx的script处理" href="chapter_14.html" />
    <link rel="prev" title="nginx的请求处理阶段 (90%)" href="chapter_12.html" /> 
  </head>
  <body lang="zh-Hans">
    <div class="related">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="chapter_14.html" title="nginx的script处理"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="chapter_12.html" title="nginx的请求处理阶段 (90%)"
             accesskey="P">上一页</a> |</li>
        <li><a href="index.html">Nginx开发从入门到精通</a> &raquo;</li>
          <li><a href="source_analysis.html" accesskey="U">下篇：nginx原理解析篇</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="nginxupstream">
<h1>nginx的upstream原理解析<a class="headerlink" href="#nginxupstream" title="永久链接至标题">¶</a></h1>
<div class="section" id="id1">
<h2>无缓冲的处理流程<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
</div>
<div class="section" id="id2">
<h2>带缓冲的处理流程<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
</div>
<div class="section" id="subrequestupstream">
<h2>subrequest访问upstream的处理流程<a class="headerlink" href="#subrequestupstream" title="永久链接至标题">¶</a></h2>
</div>
<div class="section" id="id3">
<h2>负载均衡算法<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
<div class="section" id="round-robin">
<h3>round-robin算法<a class="headerlink" href="#round-robin" title="永久链接至标题">¶</a></h3>
</div>
<div class="section" id="iphash">
<h3>基于ip的hash算法<a class="headerlink" href="#iphash" title="永久链接至标题">¶</a></h3>
</div>
</div>
<div class="section" id="upstream">
<h2>upstream缓存机制<a class="headerlink" href="#upstream" title="永久链接至标题">¶</a></h2>
</div>
<div class="section" id="id4">
<h2>常用upstream模块分析<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h2>
<div class="section" id="proxy">
<h3>proxy模块<a class="headerlink" href="#proxy" title="永久链接至标题">¶</a></h3>
</div>
<div class="section" id="fastcgi">
<h3>fastcgi模块<a class="headerlink" href="#fastcgi" title="永久链接至标题">¶</a></h3>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="http://tengine.taobao.org/">
              <img class="logo" src="_static/logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">內容目录</a></h3>
  <ul>
<li><a class="reference internal" href="#">nginx的upstream原理解析</a><ul>
<li><a class="reference internal" href="#id1">无缓冲的处理流程</a></li>
<li><a class="reference internal" href="#id2">带缓冲的处理流程</a></li>
<li><a class="reference internal" href="#subrequestupstream">subrequest访问upstream的处理流程</a></li>
<li><a class="reference internal" href="#id3">负载均衡算法</a><ul>
<li><a class="reference internal" href="#round-robin">round-robin算法</a></li>
<li><a class="reference internal" href="#iphash">基于ip的hash算法</a></li>
</ul>
</li>
<li><a class="reference internal" href="#upstream">upstream缓存机制</a></li>
<li><a class="reference internal" href="#id4">常用upstream模块分析</a><ul>
<li><a class="reference internal" href="#proxy">proxy模块</a></li>
<li><a class="reference internal" href="#fastcgi">fastcgi模块</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>上一个主题</h4>
  <p class="topless"><a href="chapter_12.html"
                        title="上一章">nginx的请求处理阶段 (90%)</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="chapter_14.html"
                        title="下一章">nginx的script处理</a></p>
  <h3>本页</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/chapter_13.txt"
           rel="nofollow">显示源代码</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>快速搜索</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="搜索" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    输入相关的模块，术语，类或者函数名称进行搜索
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="chapter_14.html" title="nginx的script处理"
             >下一页</a> |</li>
        <li class="right" >
          <a href="chapter_12.html" title="nginx的请求处理阶段 (90%)"
             >上一页</a> |</li>
        <li><a href="index.html">Nginx开发从入门到精通</a> &raquo;</li>
          <li><a href="source_analysis.html" >下篇：nginx原理解析篇</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; 版权所有 2012, taobao.
      使用 <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>